﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SCSService;

namespace SCS.Core.Models
{
    public class StockModel
    {
        #region "Language"

        public static void DeleteAllTypeByProductId(int TypeProductId)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteAllTypeByProductId(TypeProductId);
        }
        public static List<System_Language> GetListLanguage()
        {
            SCSService.LanguageService langSvc = new LanguageService();
            return langSvc.GetListLanguage();
        }
        public static void DeleteProductPriceByProductID(int productID)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteProductPriceByProductID(productID);
        }

        public static System_Language GetLanguageByID(int id)
        {
            SCSService.LanguageService langSvc = new LanguageService();
            return langSvc.GetLanguageByID(id);
        }

        public static int GetLanguageIDByCountryCode(string code)
        {
            SCSService.LanguageService langSvc = new LanguageService();
            return langSvc.GetLanguageIDByCountryCode(code);
        }
        #endregion

        #region "TypeProduct"

        public static List<Type_Product> GetListTypeProductByParentId(int? typeID,int LanguagesID,int siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByParent(typeID, LanguagesID, siteGuid,-1);
        }

        public static List<Type_Product> GetListTypeProductByParentIDSearch(string name, int? status, int? order,string param, int? typeID, int LanguagesID, int siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByParentSearch(name, status, order,param, typeID, LanguagesID, siteGuid);
        }

        public static List<Type_Product> GetListTypeProductByParentIDforEdit(string name, int? status, int? order, int? typeID,string param, int LanguagesID, int siteGuid,int idOwner)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByParentSearchForEdit(name, status, order, typeID,param, LanguagesID, siteGuid,idOwner);
        }

        public static Type_Product GetTypeProduct(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetTypeProduct(id);
        }

        public static int CreateTypeProduct(Type_Product type)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateTypeProduct(type);
        }

        public static void UpdateTypeProduct(Type_Product type)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateTypeProduct(type);
        }

        public static void UpdateStatusTypeProduct(int? id, int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusTypeProduct(id, newStatus);
        }

        public static int GetCountTypeProduct(int LanguagesID, int siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetCountTypeProduct(LanguagesID, siteGuid);
        }

        public static void UpdateSortOrder(int id, int newSort)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateSortOrder(id, newSort);
        }

        public static int GetCountProductInTypeProduct(int typeId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetCountProductInTypeProduct(typeId);
        }

        public static void DeleteTypeProduct(int typeId)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteTypeProduct(typeId);
        }

        public static List<Type_Product_Item> GetListTypeProductItemByTypeID(int? id,int siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductItemByTypeID(id,siteGuid);
        }

        public static int CreateTypeProductItem(Type_Product_Item items)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateTypeProductItem(items);
        }

        public static Type_Product_Item GetTypeProductItemByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetTypeProductItemByID(id);
        }

        public static void UpdateTypeProductforItem(Type_Product_Item items)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateTypeProductforItem(items);
        }
        public static void UpdateTypeProductByTypeProductItemId(Type_Product_Item items)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateTypeProductByTypeProductItemId(items);
        
        }
        public static Type_Product_Item GetTypeProductItemByLangIDandTypeID(int langID, int typeID)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetTypeProductItemByLangIDandTypeID(langID,typeID);
        }
        #endregion

        #region "Product"
        public static int? GetCountProduct_Stock_DetailByProductIDStatus(int? productID, int? Status, DateTime? EndDate)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetCountProduct_Stock_DetailByProductIDStatus(productID, Status, EndDate);
        }
        public static int? GetOrder_ItemByProductID_Status(int? productID, int? status)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetOrder_ItemByProductID_Status(productID, status);
        }
        public static List<Product> GetListProductByTypeProduct(string ProductNameSearch, string ProductCodeSearch, int? typeId, int LanguagesID, int siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductByTypeProductSearch(ProductNameSearch, ProductCodeSearch, typeId, LanguagesID, siteGuid);
        }

        public static Product GetProductByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProduct(id);
        }

        public static void UpdateStatus(int? id,int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusProduct(id, newStatus);
        }

        public static int CreateProduct(Product product)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateProduc(product);
        }

        public static int CreateManageTypeProduct(Type_Product_Manage manage)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateManageProduct(manage);
        }

        public static List<int> GetListTypeProductIdManageByProductID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductIdManageByProductID(id);
        }

        public static void UpdateProduct(Product pro)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateProduct(pro);
        }

        public static List<Type_Product_Manage> GetListProductManageByProductID(int proId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductManageByProductID(proId);
        }

        public static void DeleteProductManage(int manaID)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteProductManage(manaID);
        }

        public static void DeleteProduct(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteProduct(id);
        }

        public static List<Product_Item> GetListProductItemByProductID(int? id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductItemByProductID(id);
        }

        public static int CreateProductItem(Product_Item items)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateProductItem(items);
        }

        public static Product_Item GetProductItemByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductItemByID(id);
        }

        public static void UpdateProductforItem(Product_Item items)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateProductforItem(items);
        }

        public static Product_Item GetProductItemByLangIDandProductID(int langID, int proID)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductItemByLangIDandProductID(langID,proID);
        }
        #endregion

        #region "TypeProperties"
        public static List<Type_Property> GetListTypePropertyByProduct(int productId,int languageId, int status)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypePropertiesByProductID(productId, languageId, status);
        }

        public static List<Product_Property> GetListProductPropertyByType(int? typeId,int? proId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductProperties(typeId, proId);
        }

        public static Type_Property GetTypePropertiesById(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetTypePropertiesByID(id);
        }

        public static int CreateTypeProperties(Type_Property type)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateTypeProperties(type);
        }

        public static Type_Property GetTypeProperty(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetTypeProperty(id);
        }

        public static void UpdateTypeProperty(Type_Property type)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateTypeProperty(type);
        }

        public static List<Type_Property> GetListTypeProperty(int? id, int languageID, string Name, int? StatusSearch)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProperty(id, languageID, Name, StatusSearch);
        }

        public static List<Type_Property> GetListTypeProperty(int languageID, int? siteGuid)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProperty(languageID, (int)siteGuid);
        }

        public static void UpdateStatusTypeProperty(int? id, int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusTypeProperty(id, newStatus);
        }

        public static int GetCountTypePropertyInProductTypeProperty(int typeId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetCountTypePropertyInProductTypeProperty(typeId);
        }

        public static void DeleteTypeProperty(int typeId)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteTypeProperty(typeId);
        }

        public static List<Product_Type_Property> GetListProductTypePropertyByProductID(int proId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductTypePropertyByProductID(proId);
        }

        public static int CreateProductTypeProperty(Product_Type_Property ptp)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateProductTypeProperty(ptp);
        }

        public static void DeleteProductTypeProperties(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteProductTypeProperties(id);
        }

        public static int CreateProductProperties(Product_Property propro)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateProductProperties(propro);
        }

        public static Product_Property GetProductPropertiesByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductPropertiesByID(id);
        }

        public static void UpdateProductProperties(Product_Property pro)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateProductProperties(pro);
        }

        public static Product_Type_Property GetProductTypePropertiesByProIDandTypeProPerId(int proId, int typeProPerId)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductTypePropertiesByProductIDandTypePropertiesID(proId,typeProPerId);
        }
        #endregion

        #region "Product Price"
        public static Product_Price GetLastProductPriceByProductId(int id, int languageID,int? currencyID)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductPriceByProductID(id, languageID, currencyID);
        }

        public static List<Product_Price> GetListProductPriceByProductId(int id, int languageID, DateTime? StartDateSearch, DateTime? EndDateSearch, float? ValueSearch, int? StatusSearch)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductPriceByProductID(id, languageID, StartDateSearch, EndDateSearch, ValueSearch, StatusSearch);
        }

        public static void UpdateStatusPrice(int? id, int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusPrice(id, newStatus);
        }

        public static List<System_Currency> GetListCurrency()
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListCurrency();
        }

        public static System_Currency GetCurrencyByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetCurrencyByID(id);
        }

        public static int CreatePrice(Product_Price pri)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreatePrice(pri);
        }

        public static Product_Price GetProductPriceByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductPriceByID(id);
        }

        public static void UpdateProductPrice(Product_Price pri)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateProductPrice(pri);
        }

        public static void DeleteProductPrice(int priceID)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeletePrice(priceID);
        }
        #endregion

        #region "Discount"
        public static int CreateDiscount(Discount dis)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateDiscount(dis);
        }

        public static Discount GetDiscountByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetDiscountByID(id);
        }

        public static void CreateDiscountManage(Discount_Product_Manager disMana)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.CreateDiscountManage(disMana);
        }

        public static List<int> GetListProductByManageDiscountID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProducIDManageByDiscountID(id);
        }

        public static List<int> GetListTypeProductByListProductID(List<int> list)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByListProductID(list);
        }

        public static void UpdateDiscount(Discount dis)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateDiscount(dis);
        }

        public static List<Discount_Product_Manager> GetListProductManageByDiscountID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductManageByDiscountID(id);
        }

        public static void DeleteProductManageDiscount(int disId,int proId)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteProductManageDiscount(disId, proId);
        }

        public static List<Discount> GetListDiscountManagerByProductID(int? id, int languageID, DateTime? StartDateSearch, DateTime? EndDateSearch, int? ValueSearch, int? StatusSearch, int? TypeDiscounts)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListDiscountManagerByProductID(id, languageID, StartDateSearch, EndDateSearch, ValueSearch, StatusSearch, TypeDiscounts);
        }

        public static void UpdateStatusDiscount(int? id, int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusDiscount(id, newStatus);
        }

        public static void DeleteDiscount(int disID)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteDiscount(disID);
        }
        #endregion
        #region Mã hóa

        public static string Encrypt(string PlainText)
        {
            SCSService.CryptographyService crySvc = new CryptographyService();
            return crySvc.Encrypt(PlainText);
        }

        public static string Decrypt(string CipherText)
        {
            SCSService.CryptographyService crySvc = new CryptographyService();
            return crySvc.Decrypt(CipherText);
        }
        #endregion

        #region "Product Stock"
        public static List<Product_Stock> GetListProductStockByProductId(int id, DateTime? StockInSearch, DateTime? ModifyDateSearch, long? QuantitySearch, int? StatusSearch)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetListProductStockByProductID(id, StockInSearch, ModifyDateSearch, QuantitySearch, StatusSearch);
        }

        public static int CreateStock(Product_Stock sto)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.CreateStock(sto);
        }

        public static Product_Stock GetProductStockByID(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductStockByID(id);
        }

        public static void UpdateProductStock(Product_Stock sto)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateProductStock(sto);
        }

        public static void DeleteProductStock(int stockID)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.DeleteStock(stockID);
        }

        public static void UpdateStatusStock(int? id, int? newStatus)
        {
            SCSService.ProductService proSvc = new ProductService();
            proSvc.UpdateStatusStock(id, newStatus);
        }

        public static long GetProductStockByProductId(int id)
        {
            SCSService.ProductService proSvc = new ProductService();
            return proSvc.GetProductStockByProductID(id,-1);
        }
        #endregion
        #region Detail Stock -Duc
        public static int CreateProduct_Stock_Detail(Product_Stock_Detail prtProduct_Stock_Detail)
        {
            SCSService.ProductService ProductStockDetailSvc = new ProductService();
            return ProductStockDetailSvc.CreateProduct_Stock_Detail(prtProduct_Stock_Detail);

        }
        public static List<Product_Stock_Detail> getListProductStockDetail(int? id)
        {
            SCSService.ProductService proSVC = new ProductService();
            return proSVC.getListProductStockDetail(id);
        }
        public static void DeleteProduct_Stock_DetailById(int? id)
        {
            SCSService.ProductService ProSVC = new ProductService();
            ProSVC.DeleteProduct_Stock_DetailById(id);
        }
        public static void UpdateProduct_Stock_Detail(int id, string Code, string Serial)
        {
            SCSService.ProductService proSVC = new ProductService();
            proSVC.UpdateProduct_Stock_Detail(id, Code, Serial);
        }
        #endregion

    }
}